import { Drawer } from 'antd';
import React, { useState, useEffect } from 'react'
import Generator from 'fr-generator';
import 'antd/dist/antd.css'

interface Props {
  isOpen: boolean,
  closeEvent: (isOpen: boolean) => void;
  TableInfo: Generator.TableInfo;
}

const defaultValue = {
  type: 'object',
  properties: {
    inputName: {
      title: '简单输入框',
      type: 'string',
    },
  },
};

const FormConfig: React.FC<Props> = (props) => {
  const { isOpen, closeEvent, TableInfo } = props;
  const [open, setOpen] = useState(isOpen);


  const onClose = () => {
    setOpen(false);
    closeEvent(false)
  };

  useEffect(() => {
    setOpen(isOpen);
  }, [isOpen]);

  return (<Drawer
    title={`代码生成配置`}
    width={
      1000}
    onClose={onClose}
    open={open}
    placement='right'
  >
    <div style={{ height: '80vh' }}>
      <Generator defaultValue={defaultValue} />
    </div>
  </Drawer>)
}

export default FormConfig;
